import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:kegelutils/controller_events.dart';
import 'package:kegelutils/controller_main.dart';
import 'package:kegelutils/page_splash.dart';

void main() async {
  await GetStorage.init();
  // //顶部状态栏透明
  // SystemChrome.setSystemUIOverlayStyle(
  //     SystemUiOverlayStyle(statusBarColor: Colors.transparent));

  initializeDateFormatting().then((_) => runApp(
        GetMaterialApp(
          home: App(),
          routingCallback: (routing) {},
          theme: ThemeData.light().copyWith(
            shadowColor: Colors.grey[300],
            bottomAppBarColor: Colors.teal,
            backgroundColor: Colors.grey[300],
            scaffoldBackgroundColor: Colors.white,
          ),
          builder: (context, widget) {
            return MediaQuery(
              //设置文字大小不随系统设置改变
              data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
              child: widget!,
            );
          },
          // theme: ThemeData.dark().copyWith(
          //   shadowColor: Colors.black87,
          //   bottomAppBarColor: Colors.blueGrey[900],
          //   backgroundColor: Colors.grey[300],
          // ),
        ),
      ));

  if (Platform.isAndroid) {
    SystemUiOverlayStyle style = const SystemUiOverlayStyle(
      systemNavigationBarColor: Color(0xFF000000),
      systemNavigationBarDividerColor: null,

      /// 注意安卓要想实现沉浸式的状态栏 需要底部设置透明色
      statusBarColor: Colors.transparent,
      systemNavigationBarIconBrightness: Brightness.light,
      statusBarIconBrightness: Brightness.light,
      statusBarBrightness: Brightness.dark,
    );
    SystemChrome.setSystemUIOverlayStyle(style);
  }
}

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    Get.put(MainController());
    Get.put(EventsController());
    return const SplashPage();
  }
}
